package spring.cloud.order;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangjh by 2017-12-26
 */
@SpringBootApplication
@EnableEurekaClient
@RestController
@EnableHystrix
@EnableHystrixDashboard
public class OrderApplication {

	@HystrixCommand(fallbackMethod = "availableFallback")
	@RequestMapping(value = "/available",method = RequestMethod.GET)
	public String available() {
		System.out.println("Spring in Action");
		return "Spring in Action";
	}


	@RequestMapping(value = "/availableFallback", method = RequestMethod.GET)
	public String availableFallback() {
		System.out.println("Spring in Action error");
		return "Spring in Action error";
	}

	public static void main(String[] args) {
		SpringApplication.run(OrderApplication.class, args);
	}
}
